#------------------------------------------------------------------------------#
#       Add some special lines if building Library under Visual Studio         #
#------------------------------------------------------------------------------#
IF(WIN32)
  IF (NOT ONCE_SET_CMAKE_INSTALL_PREFIX)
    SET(ONCE_SET_CMAKE_INSTALL_PREFIX true CACHE BOOL
            "Have we set the install prefix yet?" FORCE)
    SET(CMAKE_INSTALL_PREFIX /usr/local CACHE PATH
        "Install path prefix, prepended onto install directories"
        FORCE)
  ENDIF (NOT ONCE_SET_CMAKE_INSTALL_PREFIX)
  
  ADD_DEFINITIONS(-D_MSC_VER) #This is needed to remove errors due to sys/time.h
  #----------------------------------------------------------------------------#
  #  Specific definitions when building the library with Visual Studio         #
  #----------------------------------------------------------------------------#
  IF(MSVC)
    ADD_DEFINITIONS(
      -D_CRT_FAR_MAPPINGS_NO_DEPRECATE
      -D_CRT_IS_WCTYPE_NO_DEPRECATE
      -D_CRT_MANAGED_FP_NO_DEPRECATE
      -D_CRT_NONSTDC_NO_DEPRECATE
      -D_CRT_SECURE_NO_DEPRECATE
      -D_CRT_SECURE_NO_WARNINGS
      -D_CRT_SECURE_NO_DEPRECATE_GLOBALS
      -D_CRT_SETERRORMODE_BEEP_SLEEP_NO_DEPRECATE
      -D_CRT_TIME_FUNCTIONS_NO_DEPRECATE
      -D_CRT_VCCLRIT_NO_DEPRECATE
      -D_SCL_SECURE_NO_DEPRECATE
      -Zc:wchar_t  # Treat wchar_t as built-in type
    )
    # This option is to enable the /MP switch for Visual Studio 2005 
    # and above compilers
    OPTION(WIN32_USE_MP
          "Set to ON to build Cbc with the /MP option (Visual Studio 2005 and above)." OFF)
    MARK_AS_ADVANCED(WIN32_USE_MP)
    IF(WIN32_USE_MP)
      SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
    ENDIF(WIN32_USE_MP)
  
    #Can set these flags; follow the pattern as shown here
    SET(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "Configs" FORCE)
    SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MT /Zi /Od /Ob1 /D NDEBUG" CACHE STRING "Flags" FORCE)
    SET(CMAKE_C_FLAGS_RELWITHDEBINFO "/MT /Zi /Od /Ob1 /D NDEBUG" CACHE STRING "Flags" FORCE)
    SET(CMAKE_CXX_FLAGS_MINSIZEREL "/MT /O1 /Ob1 /D NDEBUG" CACHE STRING "Flags" FORCE)
    SET(CMAKE_C_FLAGS_MINSIZEREL "/MT /O1 /Ob1 /D NDEBUG" CACHE STRING "Flags" FORCE)
    SET(CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG /MTd /Zi /Ob0 /Od /RTC1" CACHE STRING "Flags" FORCE)
    SET(CMAKE_C_FLAGS_DEBUG "/D_DEBUG /MTd /Zi /Ob0 /Od /RTC1" CACHE STRING "Flags" FORCE)
    SET(CMAKE_CXX_FLAGS_RELEASE "/MT /O2 /Ob2 /D NDEBUG" CACHE STRING "Flags" FORCE)
    SET(CMAKE_C_FLAGS_RELEASE "/MT /O2 /Ob2 /D NDEBUG" CACHE STRING "Flags" FORCE)
    
    #In addition, add some defines that are necessary for all libraries of Cbc
    ADD_DEFINITIONS(
                   -DWIN32 
                   -D_LIB 
                   -DUSE_CBCCONFIG 
                   -DCOIN_NO_CLP_MESSAGE 
                   -DCOIN_HAS_CLP 
                   -DCOIN_HAS_CBC 
                   -DHAVE_MATH_H
    )
  ENDIF(MSVC)
  
  #----------------------------------------------------------------------------#
  #      Specific definitions when building the library with MinGW             #
  #----------------------------------------------------------------------------#
  IF(MINGW)
    ADD_DEFINITIONS(
      -O3 
      -pipe 
      -DNDEBUG 
      -pedantic-errors 
      -Wparentheses 
      -Wreturn-type 
      -Wcast-qual 
      -Wall 
      -Wpointer-arith 
      -Wwrite-strings 
      -Wno-unknown-pragmas 
      -Wno-long-long 
      -DHAVE_CFLOAT
      -DHAVE_CMATH
      -D_CRT_SECURE_NO_WARNINGS 
      -D_CRT_SECURE_NO_DEPRECATE
      -D_SCL_SECURE_NO_WARNINGS 
      -DCOIN_FAST_CODE 
      -DCLP_FAST_CODE 
      -DCOIN_NO_TEST_DUPLICATE
      -DUSE_CBCCONFIG 
      -DCOIN_NO_CLP_MESSAGE
      -DCOIN_HAS_CLP
    )
  ENDIF(MINGW)
ENDIF(WIN32)
